<?php
$status=$_GET["status"];
	
$db = mysql_connect("mysql513.in.shared-server.net:16033", "JRtu434", "qvoiceDB1");
mysql_select_db("JRtu434", $db);
$result = mysql_query("Select projects.ID as ID,
			name as name,sum(if(status=\"complete\",1,0)) as complete,
			sum(if(status=\"screenout\",1,0)) as screenout,
			sum(if(status=\"quotafull\",1,0)) as quotafull,
			sum(if(status=\"short\",1,0)) as short,
			sum(if(status=\"gate\",1,0)) as gate,
			sum(if(status is null,1,0)) as empty,
			sum(if(status=\"complete\",1,0))/(sum(if(status=\"complete\",1,0))+sum(if(status=\"screenout\",1,0)))*100 as IR
			from testredirect,projects
			where testredirect.rid=projects.rid
			and state=\"live\" group by name");


	echo "<table border='1'>";
	echo "<td>" ."Close". "</td>";
	echo "<td>" ."Download". "</td>";
	echo "<td>" ."Name". "</td>";
	echo "<td>" ."Complete". "</td>";
	echo "<td>" ."Screenout" . "</td>";
	echo "<td>" ."Quotafull" . "</td>";
	echo "<td>" ."Short" . "</td>";
	echo "<td>" ."Gate" . "</td>";
	echo "<td>" ."In Progress" . "</td>";
	echo "<td>" ."IR %" . "</td>";
	echo "</tr>";
	while($row = mysql_fetch_array($result))
	  {
	  echo "<tr><td><input type=\"checkbox\" name=\"close[]\" value=\"".$row['name'] ."\"></td>";
	  echo "<td><input type=\"radio\" name=\"download\" value=\"".$row['name'] ."\"></td>";
	  echo "<td>" . $row['name'] . "&nbsp;&nbsp;&nbsp;</td>";
	  echo "<td>" . $row['complete'] . "</td>";
	  echo "<td>" . $row['screenout'] . "</td>";
	  echo "<td>" . $row['quotafull'] . "</td>";
	  echo "<td>" . $row['short'] . "</td>";
	  echo "<td>" . $row['gate'] . "</td>";
	  echo "<td>" . $row['empty'] . "</td>";
	  echo "<td>" . $row['IR'] . "</td>";
	  echo "</tr>";
	  }
  echo "</table>";
			  
 mysql_close();


?> 